home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************
- ;
- ; $mat.asm
- ;
- ; staff
- ;
- ; 03-26-88
- ;
- ; (C) Texas Instruments Inc., 1992
- ;
- ; Refer to the file 'license.txt' included with this
- ; this package for usage and license information.
- ;
- ;**************************************************************
- Example 34. Matrix times a vector multiplication
- ;
- ;==============================================================================
- ; SUBROUTINE M A T
- ;==============================================================================
- ; MAT == MATRIX TIMES A VECTOR OPERATION
- ;
- ;
- ; TYPICAL CALLING SEQUENCE:
- ;
- ; load AR0
- ; load AR1
- ; load AR2
- ; load AR3
- ; load R1
- ; CALL MAT
- ;
- ;
- ; ARGUMENT ASSIGNMENTS:
- ; argument | function
- ; ---------+-----------------------
- ; AR0 | address of m(0,0)
- ; AR1 | address of v(0)
- ; AR2 | address of p(0)
- ; AR3 | number of rows - 1 (numrows-1)
- ; R1 | number of columns - 2 (numcols-2)
- ;
- ; REGISTERS USED AS INPUT: AR0, AR1, AR2, AR3, R1
- ; REGISTERS MODIFIED: R0, R2, AR0, AR1, AR2, AR3, IR0,
- ; RC, RSA, REA
- ;
- ;
- ; PROGRAM SIZE: 11
- ;
- ; EXECUTION CYCLES: 6 + 10 * numrows + numrows * (numcols - 1)
- ;
- ;==============================================================================
- ;
- .global MAT
- ;
- ; setup
- ;
- MAT LDI R1,IR0 ; number of columns-2 -> IR0
- ADDI 2,IR0 ; IR0 = numcols
- ;
- ; for (i = 0; i < numrows; i++) loop over the rows.
- ;
- ROWS LDF 0.0,R2 ; initialize R2
- MPYF3 *AR0++(1),*AR1++(1),R0 ; m(i,0) * v(0) -> R0
- ;
- ; for (j = 1; j < numcols; j++) do dot product over columns
- ;
- RPTS R1 ; multiply a row by a column.
- ;
- MPYF3 *AR0++(1),*AR1++(1),R0 ; m(i,j) * v(j) -> R0.
- || ADDF3 R0,R2,R2 ; m(i,j-1) * v(j-1) + R2 -> R2.
- ;
- DBD AR3,ROWS ; counts the number of rows left.
- ;
- ADDF R0,R2 ; last accumulate.
- STF R2,*AR2++(1) ; result -> p(i)
- NOP *--AR1(IR0) ; set AR1 to point to v(0).
- ; !!! delayed branch happens here !!!
- ;
- ; return sequence
- ;
- RETS ; return
- ;
- ; end
- ;
- .end